<%--
  Created by IntelliJ IDEA.
  User: Yy
  Date: 2022/5/15
  Time: 15:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>新增成绩</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery-3.5.1.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/ajaxForm.js"></script>
    <script>
        layui.use(['form', 'laydate', 'layer','jquery'], function () {
            var form = layui.form, laydate = layui.laydate, layer = layui.layer,$=layui.jquery;
            laydate.render({
                elem: '#scoreTime',
                type: 'date',//指定日期选择器类型 date,time,datetime
                trigger: 'click'
            });


            //监听表单提交
            form.on('submit(formbtn)', function () {
                $("#formsbt").ajaxSubmit({
                    type: "post",
                    url: '${pageContext.request.contextPath}/stu/addstuscore',
                    success: function (data) {//添加成功的回调函数
                        var index = parent.layer.getFrameIndex(window.name);//获取Frame索引
                        parent.layer.close(index);//关闭当前frame
                        parent.layui.table.reload("titleStu");//可以对父窗口进行刷新
                    }
                });
            });
            form.verify({
                score1: function(value, item){ //value：表单的值、item：表单的DOM对象
                    // if (!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)) {
                    //     return '不能有特殊字符';
                    // }
                    //如果不想自动弹出默认提示框，可以直接返回 true，这时你可以通过其他任意方式提示（v2.5.7 新增）
                    if (value > 100) {
                        // alert('不能大于50分');
                        return '不能大于100分';
                    }
                }
            });
        });
    </script>

</head>
<body>
    <form class="layui-form" id="formsbt" >
        <%--        成绩id--%>
        <div class="layui-form-item">
            <div class="layui-input-inline">
                <input type="hidden" name="scoreId" id="scoreId"
                       autocomplete="off" class="layui-input" >
            </div>
        </div>
        <%--        录入人员id--%>
        <div class="layui-form-item">
            <div class="layui-input-inline">
                <input type="hidden" name="empId" id="empId" value="${sessionScope.emp.empId}"
                       autocomplete="off" class="layui-input" >
            </div>
        </div>
            <%--    学生--%>
        <div class="layui-form-item">
            <label class="layui-form-label">学生:</label>
            <div class="layui-input-inline">
                <select name="stuId">
                    <c:forEach items="${stulist}" var="e">
                        <option value="${e.stuId}">${e.stuname}</option>
                    </c:forEach>
                </select>
            </div>
        </div>
        <%--    学生成绩--%>
        <div class="layui-form-item">
            <label class="layui-form-label">学生成绩</label>
            <div class="layui-input-inline">
                <input type="text" name="score" id="score"  placeholder="学生成绩"
                       class="layui-input" lay-verify="required|score1" />
            </div>
            <div class="layui-form-mid layui-word-aux">必填项</div>
        </div>
        <%--    补考成绩--%>
        <div class="layui-form-item">
            <label class="layui-form-label">补考成绩</label>
            <div class="layui-input-inline">
                <input type="text" name="rescore" id="rescore"  placeholder="补考成绩"
                       class="layui-input" lay-verify="required|score1"/>
            </div>
            <div class="layui-form-mid layui-word-aux">必填项</div>
        </div>

        <%--    课程--%>
        <div class="layui-form-item">
            <label class="layui-form-label">课程:</label>
            <div class="layui-input-inline">
                <select name="courseId">
                    <c:forEach items="${clist}" var="e">
                        <option value="${e.courseId}">${e.courseName}</option>
                    </c:forEach>
                </select>
            </div>
        </div>
        <%--    考试类型--%>
        <div class="layui-form-item">
            <label class="layui-form-label">考试类型:</label>
            <div class="layui-input-inline">
                <select name="testType">
                    <option value="1">笔试</option>
                    <option value="2">机试</option>
                    <option value="3">模拟面试</option>
                </select>
            </div>
        </div>
        <%--    学期--%>
        <div class="layui-form-item">
            <label class="layui-form-label">学期:</label>
            <div class="layui-input-inline">
                <select name="termId">
                    <c:forEach items="${tlist}" var="e">
                        <option value="${e.termId}">${e.termName}</option>
                    </c:forEach>
                </select>
            </div>
        </div>
        <%--    考试时间--%>
        <div class="layui-form-item">
            <label class="layui-form-label">考试时间</label>
            <div class="layui-input-inline">
                <input type="text" name="scoreTime" id="scoreTime"  placeholder="考试时间"
                       autocomplete="off" class="layui-input" lay-verify="required">
            </div>
            <div class="layui-form-mid layui-word-aux">必填项</div>
        </div>
        <%--    备注--%>
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-inline">
                <input type="text" name="remark" id="remark" required lay-verify="" placeholder="备注"
                       autocomplete="off" class="layui-input" >
            </div>
            <div class="layui-form-mid layui-word-aux">必填项</div>
        </div>

        <%--    备注--%>
        <div class="layui-form-item">
            <div class="layui-input-inline">
                <input type="hidden" name="testName" id="testName" required lay-verify="" placeholder="备注"
                       autocomplete="off" class="layui-input" >
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <button id="formbtn" type="button" lay-submit lay-filter="formbtn" class="layui-btn layui-btn-normal">
                提交
            </button>
            <button id="reset" type="reset" class="layui-btn layui-btn-normal">
                重置
            </button>
        </div>
    </form>
</body>
</html>
